package controllers

/** Created by yz on 2017/5/31.
  */

import command.CommandExec
import dao._
import implicits.Implicits._
import play.api.mvc._
import shared.Pojo._
import shared.tsPojo.TsPojo
import tool.Pojo.CommandData
import tool.{FormTool, Tool}
import ujson.play.PlayJson
import upickle.default._
import utils.Utils

import java.io.File
import javax.inject.Inject
import scala.collection.immutable.SeqMap
import scala.concurrent.ExecutionContext.Implicits.global

class MarkerController @Inject() (cc: ControllerComponents)(implicit
    val basicDao: MarkerDao
) extends AbstractController(cc) {

  def allByServer = Action.async { implicit request =>
    val obj = PlayJson.transform(request.body.asJson.get, reader[ujson.Obj])
    val pageData = FormTool.pageForm.bindFromRequest().get
    basicDao.selectAll(obj.value, pageData).map { case (size, x) =>
      val array = Utils.getJsonByTs(x)
      Ok(ujson.Obj("rows" -> array, "total" -> size))
    }
  }

}
